<meta charset = " utf-8"/>
<script>	
         	var str = parseInt(prompt("请输入考试科目的数量："));
	var sum = 0;
	
	if(str<=0){
		alert("您输入的数量不对");
	}else{
		for(i = 1;i<=str;i++){
			var s = parseInt(prompt("请输入考试科目的分数："));
            if(s<=0){alert("你输入的成绩有误");break;}else
			{sum=sum + s;}
		
		}
        alert(str + "门科目总分为：" + sum);
	}
	
	

</script>